package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusHardwareUses;
import com.ruoyi.business.service.IBusHardwareUsesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 硬件使用情况表Controller
 * 
 * @author asher
 * @date 2021-11-02
 */
@RestController
@RequestMapping("/business/hardware_uses")
public class BusHardwareUsesController extends BaseController
{
    @Autowired
    private IBusHardwareUsesService busHardwareUsesService;

    /**
     * 查询硬件使用情况表列表
     */
    @PreAuthorize("@ss.hasPermi('business:hardware_uses:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusHardwareUses busHardwareUses)
    {
        startPage();
        List<BusHardwareUses> list = busHardwareUsesService.selectBusHardwareUsesList(busHardwareUses);
        return getDataTable(list);
    }

    /**
     * 导出硬件使用情况表列表
     */
    @PreAuthorize("@ss.hasPermi('business:hardware_uses:export')")
    @Log(title = "硬件使用情况表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusHardwareUses busHardwareUses)
    {
        List<BusHardwareUses> list = busHardwareUsesService.selectBusHardwareUsesList(busHardwareUses);
        ExcelUtil<BusHardwareUses> util = new ExcelUtil<BusHardwareUses>(BusHardwareUses.class);
        return util.exportExcel(list, "硬件使用情况表数据");
    }

    /**
     * 获取硬件使用情况表详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:hardware_uses:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(busHardwareUsesService.selectBusHardwareUsesByRecordId(recordId));
    }

    /**
     * 新增硬件使用情况表
     */
    @PreAuthorize("@ss.hasPermi('business:hardware_uses:add')")
    @Log(title = "硬件使用情况表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusHardwareUses busHardwareUses)
    {
        return toAjax(busHardwareUsesService.insertBusHardwareUses(busHardwareUses));
    }

    /**
     * 修改硬件使用情况表
     */
    @PreAuthorize("@ss.hasPermi('business:hardware_uses:edit')")
    @Log(title = "硬件使用情况表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusHardwareUses busHardwareUses)
    {
        return toAjax(busHardwareUsesService.updateBusHardwareUses(busHardwareUses));
    }

    /**
     * 删除硬件使用情况表
     */
    @PreAuthorize("@ss.hasPermi('business:hardware_uses:remove')")
    @Log(title = "硬件使用情况表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(busHardwareUsesService.deleteBusHardwareUsesByRecordIds(recordIds));
    }
}
